#!/usr/bin/perl
use strict;
use warnings; 

#MoTDStats is released under the MIT License, a copy is provided in the INFO.html file.
#Remember, this isn't Currys or Comet, there's no warranty (Extended or otherwise) available for this code, no matter how much money you want to pay, or however you plead/kick, scream and shout ;)

#This is version 0.0.0b ("Fixes" for QNXisms, changed $USER to $LOGNAME, new fancy HTML version of the INFO file).

#Change these settings to suit, comments are provided next to each option you can change.
my $ColourPrinting = 1; # 1 turns username/date banner colour on, 0 turns it off 
my $DFPlatform = "Autodetect"; #Setting this to Autodetect should work for a large number of systems. If the formatting looks wrong for your system, you can override this as usual. 
#If you're using QNX, set this to "QNX" and $DFNode below to "hd", or it won't work.

my $DFNode="sd"; #Linux: sd or hd, FreeBSD: da or ad , Darwin: disk, QNX: hd

#These are for internal use only, do not modify them!
my $uname=`uname -sm`; #I've yet to find a platform this doesn't work on.
my $username=`echo -n \$LOGNAME`; #Was $USER, now $LOGNAME (Seems to be more portable)
my $date=`date`;



sub UNAME {
    print "You're running on $uname\n";
}

sub UserDate {
    my $qnxuser=`echo -n \$LOGNAME`;
    if ($ColourPrinting == 1) {
    use Term::ANSIColor qw(:constants);
    $Term::ANSIColor::AUTORESET = 1;
print WHITE ON_BLUE "Currently logged in as $username. Today is $date";
}

   if ($ColourPrinting == 0) {
print "Currently logged in as $username. Today is $date";

} 
   print "\n";
}

sub DiskFree {

my $Auto=`uname -s`;
my $GNUdf_hOut="Filesystem            Size  Used Avail Use% Mounted on\n";
my $QNXPOSIXdf_Out="Filesystem            512-blocks      Used Available Capacity Mounted on\n";

    if ($DFPlatform eq "Autodetect") {
    if ($Auto eq "$Auto") {
    my $DiskFreeInfo_sd=`df -h | grep $DFNode`;
    print "$GNUdf_hOut";
    print "$DiskFreeInfo_sd\n";
 }
}

if ($DFPlatform eq "QNX") {
    print "$QNXPOSIXdf_Out";
    print `df -P | grep $DFNode`;
    print "\n";
 }
}
UserDate();
UNAME();
DiskFree();
